package logic

import (
	"context"
	"month/videosvr/video"

	"month/client/internal/svc"
	"month/client/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type CommentLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewCommentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CommentLogic {
	return &CommentLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *CommentLogic) Comment(req *types.CommentReq) (resp *types.Res, err error) {
	// todo: add your logic here and delete this line
	_, err = l.svcCtx.VideoRpc.Comment(l.ctx, &video.CommentReq{
		CommentId: req.Id,
		Userid:    int64(req.Userid),
		Comment:   req.Comment,
	})
	if err != nil {
		return &types.Res{
			Code: -1,
			Msg:  err.Error(),
			Data: nil,
		}, nil
	}
	return &types.Res{
		Code: 200,
		Msg:  "success",
		Data: nil,
	}, nil
}
